package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.CategoryDTO;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import com.sky.entity.Employee;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Auther: zhaoss
 * @Date: 2023/4/29 - 04 - 29 - 16:29
 * @Description: com.sky.mapper
 * @version: 1.0
 */
@Mapper
public interface CategoryMapper {
    /**
     * 分页查询菜品套餐
     * @param dto
     * @return
     */
    Page<Category> page(CategoryPageQueryDTO dto);

    /**
     * 根据名称查询
     * @param name
     * @return
     */
    @Select("select * from category where name = #{name}")
    Category getByName(String name);/**
     * 根据id查询
     * @param id
     * @return
     */
    @Select("select * from category where id = #{id}")
    Category getById(Long id);

    /**
     * 新增
     * @param
     */
    @Insert("insert into category (name,sort,status,type,create_time,update_time,create_user,update_user) " +
            "values (#{name},#{sort},#{status},#{type},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    @AutoFill(OperationType.INSERT)
    void add(Category category);

    /**
     * type查询
     * @param
     * @return
     */
    List<Category> getByType(Integer type);

    /**
     * 修改
     * @return
     */
    @AutoFill(OperationType.UPDATE)
    void put(Category category);

    /**
     * 删除
     * @param id
     */
    @Delete("delete from category where id = #{id}")
    void delete(Long id);


}
